﻿using System;
using System.Collections.Generic;

namespace SimpleWorkflow.Event
{
    public class WeakEvent
    {
        public string Name { get; set; }
        private List<EventHandler> Listeners { get; set; }

        public WeakEvent()
        {
            Listeners = new List<EventHandler>();
        }

        public void Add(EventHandler handler)
        {
            Listeners.Add(handler);
        }

        public void Remove(EventHandler handler)
        {
            Listeners.Remove(handler);
        }

        public void Fire(object sender, EventArgs args)
        {
            foreach (var handler in Listeners)
                handler(sender, args);
        }


    }
}
